<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Province extends Model
{
    /**
     * 表名
     *
     * @var string
     */
    protected $table = 'province';

    /**
     * 主键字段
     *
     * @var string
     */
    protected $primaryKey = 'province_id';

    /**
     * 是否自动维护时间戳
     *
     * @var bool
     */
    public $timestamps = false;

    /**
     * 可批量赋值的属性
     *
     * @var array
     */
    protected $fillable = [
        'province_name',
        'is_enabled',
        'order',
        'spell',
        'short_name',
        'initials',
        'region',
        'culture_score_count',
        'exam_score_count',
        'gaokao_province_id'
    ];

    /**
     * 属性类型转换
     *
     * @var array
     */
    protected $casts = [
        'is_enabled' => 'boolean',
        'order' => 'integer',
        'culture_score_count' => 'integer',
        'exam_score_count' => 'integer',
        'gaokao_province_id' => 'integer'
    ];

    /**
     * 获取省份名称
     *
     * @return string
     */
    public function getNameAttribute()
    {
        return $this->province_name;
    }

    /**
     * 检查省份是否启用
     *
     * @return bool
     */
    public function isEnabled()
    {
        return (bool)$this->is_enabled;
    }
}
